#include <iostream>
using namespace std;
#include <string>
#include "my_string.h"

int main(int argc, const char *argv[]){
    string s1;
    cout << s1 << endl;
    string s2("hello");
    cout << s2 << endl;
    string s3 = "beijing";
    cout << s3 << endl;
    string s4(5, 'a');
    cout << s4 << endl;
    string s5(s2);
    cout << s5 << endl;
    string s6;
    string s7;
    s7 = s6 = s3;
    cout << s6 << endl;
    cout << s7 << endl;
    if(s1.empty()){
        cout << "yes" <<endl; // yes
    }else{
        cout << "no" << endl;
    }
    if(s2.empty()){
        cout << "yes" <<endl;
    }else{
        cout << "no" << endl; // no
    }
    cout << s7.size() << endl;
    s2.at(1) = 'E';
    cout << s2.at(1) << endl;
    cout << s2 << endl; // hEllo
    cout << "--------------------" << endl;
    string str1 = "hello";
    string str2 = "beijing";
    cout << str1 << " " << str2 << endl;
    string str3;
    str3 = str1 + str2;
    cout << str3 << endl; // hellobeijing

    str2 += str1;
    cout << str2 << endl; // beijinghello

    string str4 = "xja";
    string str5 = "xja";
    cout << boolalpha << (str4==str5) << endl;

    // string str6;
    // cin >> str6;
    // cout << str6 << endl;

    string str7;
    str7 = "good";
    cout << str7 << endl;

    cout << "---------------------------------------------" << endl;
    my_string ss1;
    printf("%s\n", ss1.c_str());
    my_string ss2("hello");
    printf("%s\n", ss2.c_str());
    my_string ss3 = "beijing";
    printf("%s\n", ss3.c_str());
    my_string ss4(5, 'a');
    printf("%s\n", ss4.c_str());
    my_string ss5(ss2);
    printf("%s\n", ss5.c_str());
    my_string ss6;
    my_string ss7;
    ss7 = ss6 = ss3;
    printf("%s\n", ss6.c_str());
    printf("%s\n", ss7.c_str());
    if(ss1.empty()){
        cout << "yes" <<endl; // yes
    }else{
        cout << "no" << endl;
    }
    if(ss2.empty()){
        cout << "yes" <<endl;
    }else{
        cout << "no" << endl; // no
    }
    cout << ss7.size() << endl;
    ss2.at(1) = 'E';
    cout << ss2.at(1) << endl;
    printf("%s\n", ss2.c_str()); // hEllo
    cout << "--------------------" << endl;
    my_string sstr1 = "hello";
    my_string sstr2 = "beijing";
    cout << sstr1 << " " << sstr2 << endl;
    my_string sstr3;
    sstr3 = sstr1 + sstr2;
    cout << sstr3 << endl; // hellobeijing

    sstr2 += sstr1;
    cout << sstr2 << endl; // beijinghello

    my_string sstr4 = "xja";
    my_string sstr5 = "xja";
    cout << boolalpha << (sstr4==sstr5) << endl;

    // my_string sstr6;
    // cin >> sstr6;
    // cout << sstr6 << endl;

    // 对于下面的用法  如果类中没有提供 参数为 (const char *) 的拷贝赋值函数
    // 默认会执行 匿名对象的有参构造 然后执行 sstr7的拷贝赋值 (const my_string &)
    // 如果类中提供了 参数为 (const char *) 的拷贝赋值函数
    // 则直接会调用 sstr7 的  (const char *) 版本的拷贝赋值函数
    my_string sstr7;
    sstr7 = "good";
    cout << sstr7 << endl;

    return 0;
}